package io.github.tangwan.algorithm;

/**
 * @author tangwan
 * @version V1.0
 * created on 2021/10/8 14:10
 * @since JDK 1.8
 */
public class 判定字符是否唯一 {

    public static void main(String[] args) {
        System.out.println(isUnique("leetcode"));
        System.out.println(isUnique("abc"));
        System.out.println(isUnique("AbcBc"));
        System.out.println(isUnique("张张三李四"));
    }

    public static boolean isUnique(String astr) {
        for (int i = 0; i < astr.length(); i++) {
            if(astr.lastIndexOf(astr.charAt(i)) != i){
                return false;
            }
        }
        return true;
    }

}
